package com.wyc.service.impl;

import com.wyc.dao.CensusMessageMapper;
import com.wyc.pojo.CensusMessage;
import com.wyc.service.CensusMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName CensusMessage
 * @Author 王韫琛
 * @Date 2021/1/10 1:55
 * @Version 1.0
 */
@Service
public class CensusMessageServiceImp implements CensusMessageService {
    @Autowired
    private CensusMessageMapper censusMessageMapper;
    //超级管理员添加一个住户信息
    @Override
    public int addHouseInfo(CensusMessage censusMessage) {

        return censusMessageMapper.addHouseInfo(censusMessage);
    }
    //检查身份证是否已经存在
    @Override
    public CensusMessage findCensusMessageIdentityCard(String identity_card) {
        return censusMessageMapper.findCensusMessageIdentityCard(identity_card);
    }
    //检查手机号是否已经存在
    @Override
    public CensusMessage findCensusMessagePhone(String phone) {
        return censusMessageMapper.findCensusMessagePhone(phone);
    }
    //获取census_message表中所有的数据
    @Override
    public int getTotal() {
        return censusMessageMapper.getTotal();
    }
    //查询所有数据的方法
    @Override
    public List<CensusMessage> findPage(Integer pageNum, Integer pageSize) {
        pageNum = (pageNum-1)*pageSize;
        List<CensusMessage> list = censusMessageMapper.queryAllUser(pageNum,pageSize);
        return list;
    }
    //根据身份证查询住户
    @Override
    public List<CensusMessage> selectIdentitycard(String identity_card) {
        System.out.println(identity_card);
        return censusMessageMapper.selectIdentitycard(identity_card);
    }
    //删除住户
    @Override
    public int deleteHouseInfoById(Integer id) {
        return censusMessageMapper.deleteHouseInfoById(id);
    }
    //修改住户信息
    @Override
    public int updateHouseInfo(CensusMessage censusMessage) {
        System.out.println(censusMessageMapper.updateHouseInfo(censusMessage));
        return censusMessageMapper.updateHouseInfo(censusMessage);
    }
}
